<?php
/**
 * Created by PhpStorm.
 * Date: 2022/11/24 11:03
 */

namespace App\Traits;

trait RangeSearch
{
    /**
     * 查询数字范围，有覆盖部分就算合理
     *
     * @param $query
     * @param int $start
     * @param int $end
     * @return mixed
     */
    public function scopeRange($query, int $start, int $end)
    {
        return $query->whereNot('amount_end', '<', $start)
            ->whereNot('amount_start', '>', $end);
    }
}
